home *** CD-ROM | disk | FTP | other *** search
/ Aminet 3 / Aminet 3 - July 1994.iso / Aminet / dev / c / flex246.lha / parse.c < prev    next >
C/C++ Source or Header  |  1994-02-15  |  48KB  |  1,931 lines

  1.  
  2. /*  A Bison parser, made from parse.y with Bison version GNU Bison version 1.22
  3.   */
  4.  
  5. #define YYBISON 1  /* Identify Bison output.  */
  6.  
  7. #define    CHAR    258
  8. #define    NUMBER    259
  9. #define    SECTEND    260
  10. #define    SCDECL    261
  11. #define    XSCDECL    262
  12. #define    WHITESPACE    263
  13. #define    NAME    264
  14. #define    PREVCCL    265
  15. #define    EOF_OP    266
  16.  
  17. #line 5 "parse.y"
  18.  
  19. /*-
  20.  * Copyright (c) 1990 The Regents of the University of California.
  21.  * All rights reserved.
  22.  *
  23.  * This code is derived from software contributed to Berkeley by
  24.  * Vern Paxson.
  25.  * 
  26.  * The United States Government has rights in this work pursuant
  27.  * to contract no. DE-AC03-76SF00098 between the United States
  28.  * Department of Energy and the University of California.
  29.  *
  30.  * Redistribution and use in source and binary forms are permitted provided
  31.  * that: (1) source distributions retain this entire copyright notice and
  32.  * comment, and (2) distributions including binaries display the following
  33.  * acknowledgement:  ``This product includes software developed by the
  34.  * University of California, Berkeley and its contributors'' in the
  35.  * documentation or other materials provided with the distribution and in
  36.  * all advertising materials mentioning features or use of this software.
  37.  * Neither the name of the University nor the names of its contributors may
  38.  * be used to endorse or promote products derived from this software without
  39.  * specific prior written permission.
  40.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
  41.  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  42.  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  43.  */
  44.  
  45. /* $Header: /home/daffy/u0/vern/flex/RCS/parse.y,v 2.15 93/12/09 13:57:23 vern Exp $ */
  46.  
  47.  
  48. /* Some versions of bison are broken in that they use alloca() but don't
  49.  * declare it properly.  The following is the patented (just kidding!)
  50.  * #ifdef chud to fix the problem, courtesy of Francois Pinard.
  51.  */
  52. #ifdef YYBISON
  53. /* AIX requires this to be the first thing in the file.  */
  54. #ifdef __GNUC__
  55. #define alloca __builtin_alloca
  56. #else /* not __GNUC__ */
  57. #if HAVE_ALLOCA_H
  58. #include <alloca.h>
  59. #else /* not HAVE_ALLOCA_H */
  60. #ifdef _AIX
  61.  #pragma alloca
  62. #else /* not _AIX */
  63. #ifndef AMIGA
  64. char *alloca ();
  65. #endif
  66. #endif /* not _AIX */
  67. #endif /* not HAVE_ALLOCA_H */
  68. #endif /* not __GNUC__ */
  69. #endif /* YYBISON */
  70.  
  71. /* Bletch, ^^^^ that was ugly! */
  72.  
  73.  
  74. #include "flexdef.h"
  75.  
  76. int pat, scnum, eps, headcnt, trailcnt, anyccl, lastchar, i, actvp, rulelen;
  77. int trlcontxt, xcluflg, cclsorted, varlength, variable_trail_rule;
  78. int *active_ss;
  79. Char clower();
  80. void build_eof_action();
  81. void yyerror();
  82.  
  83. static int madeany = false;  /* whether we've made the '.' character class */
  84. int previous_continued_action;    /* whether the previous rule's action was '|' */
  85.  
  86. /* On some over-ambitious machines, such as DEC Alpha's, the default
  87.  * token type is "long" instead of "int"; this leads to problems with
  88.  * declaring yylval in flexdef.h.  But so far, all the yacc's I've seen
  89.  * wrap their definitions of YYSTYPE with "#ifndef YYSTYPE"'s, so the
  90.  * following should ensure that the default token type is "int".
  91.  */
  92. #define YYSTYPE int
  93.  
  94.  
  95. #ifndef YYLTYPE
  96. typedef
  97.   struct yyltype
  98.     {
  99.       int timestamp;
  100.       int first_line;
  101.       int first_column;
  102.       int last_line;
  103.       int last_column;
  104.       char *text;
  105.    }
  106.   yyltype;
  107.  
  108. #define YYLTYPE yyltype
  109. #endif
  110.  
  111. #ifndef YYSTYPE
  112. #define YYSTYPE int
  113. #endif
  114. #include <stdio.h>
  115.  
  116. #ifndef __cplusplus
  117. #ifndef __STDC__
  118. #define const
  119. #endif
  120. #endif
  121.  
  122.  
  123.  
  124. #define    YYFINAL        85
  125. #define    YYFLAG        -32768
  126. #define    YYNTBASE    32
  127.  
  128. #define YYTRANSLATE(x) ((unsigned)(x) <= 266 ? yytranslate[x] : 53)
  129.  
  130. static const char yytranslate[] = {     0,
  131.      2,     2,     2,     2,     2,     2,     2,     2,     2,    12,
  132.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  133.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  134.      2,     2,     2,    26,     2,    18,     2,     2,     2,    27,
  135.     28,    16,    21,    17,    31,    25,    20,     2,     2,     2,
  136.      2,     2,     2,     2,     2,     2,     2,     2,     2,    14,
  137.      2,    15,    22,     2,     2,     2,     2,     2,     2,     2,
  138.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  139.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  140.     29,     2,    30,    13,     2,     2,     2,     2,     2,     2,
  141.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  142.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  143.      2,     2,    23,    19,    24,     2,     2,     2,     2,     2,
  144.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  145.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  146.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  147.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  148.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  149.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  150.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  151.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  152.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  153.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  154.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  155.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  156.      2,     2,     2,     2,     2,     1,     2,     3,     4,     5,
  157.      6,     7,     8,     9,    10,    11
  158. };
  159.  
  160. #if YYDEBUG != 0
  161. static const short yyprhs[] = {     0,
  162.      0,     6,     7,    13,    14,    17,    19,    21,    23,    27,
  163.     29,    31,    36,    37,    38,    42,    45,    48,    50,    53,
  164.     55,    57,    61,    65,    69,    70,    73,    75,    77,    80,
  165.     84,    87,    89,    93,    95,    98,   101,   103,   106,   109,
  166.    112,   119,   125,   130,   132,   134,   136,   140,   144,   146,
  167.    150,   155,   160,   163,   164,   167
  168. };
  169.  
  170. static const short yyrhs[] = {    33,
  171.     34,    35,    38,    39,     0,     0,    34,    36,     8,    37,
  172.     12,     0,     0,     1,    12,     0,     5,     0,     6,     0,
  173.      7,     0,    37,     8,     9,     0,     9,     0,     1,     0,
  174.     38,    39,    40,    12,     0,     0,     0,    41,    13,    45,
  175.      0,    41,    45,     0,    13,    45,     0,    45,     0,    41,
  176.     11,     0,    11,     0,     1,     0,    14,    42,    15,     0,
  177.     14,    16,    15,     0,    42,    17,    44,     0,     0,    43,
  178.     44,     0,     1,     0,     9,     0,    47,    46,     0,    47,
  179.     46,    18,     0,    46,    18,     0,    46,     0,    46,    19,
  180.     48,     0,    48,     0,    46,    20,     0,    48,    49,     0,
  181.     49,     0,    49,    16,     0,    49,    21,     0,    49,    22,
  182.      0,    49,    23,     4,    17,     4,    24,     0,    49,    23,
  183.      4,    17,    24,     0,    49,    23,     4,    24,     0,    25,
  184.      0,    50,     0,    10,     0,    26,    52,    26,     0,    27,
  185.     46,    28,     0,     3,     0,    29,    51,    30,     0,    29,
  186.     13,    51,    30,     0,    51,     3,    31,     3,     0,    51,
  187.      3,     0,     0,    52,     3,     0,     0
  188. };
  189.  
  190. #endif
  191.  
  192. #if YYDEBUG != 0
  193. static const short yyrline[] = { 0,
  194.     84,   113,   126,   127,   128,   132,   145,   148,   152,   155,
  195.    158,   162,   163,   166,   177,   197,   208,   232,   243,   246,
  196.    265,   269,   271,   280,   282,   284,   284,   288,   309,   364,
  197.    367,   410,   428,   434,   439,   466,   474,   478,   485,   491,
  198.    497,   525,   539,   558,   580,   598,   605,   608,   611,   622,
  199.    625,   632,   660,   671,   679,   689
  200. };
  201.  
  202. static const char * const yytname[] = {   "$","error","$illegal.","CHAR","NUMBER",
  203. "SECTEND","SCDECL","XSCDECL","WHITESPACE","NAME","PREVCCL","EOF_OP","'\\n'",
  204. "'^'","'<'","'>'","'*'","','","'$'","'|'","'/'","'+'","'?'","'{'","'}'","'.'",
  205. "'\"'","'('","')'","'['","']'","'-'","goal","initlex","sect1","sect1end","startconddecl",
  206. "namelist1","sect2","initforrule","flexrule","scon","namelist2","@1","sconname",
  207. "rule","re","re2","series","singleton","fullccl","ccl","string",""
  208. };
  209. #endif
  210.  
  211. static const short yyr1[] = {     0,
  212.     32,    33,    34,    34,    34,    35,    36,    36,    37,    37,
  213.     37,    38,    38,    39,    40,    40,    40,    40,    40,    40,
  214.     40,    41,    41,    42,    43,    42,    42,    44,    45,    45,
  215.     45,    45,    46,    46,    47,    48,    48,    49,    49,    49,
  216.     49,    49,    49,    49,    49,    49,    49,    49,    49,    50,
  217.     50,    51,    51,    51,    52,    52
  218. };
  219.  
  220. static const short yyr2[] = {     0,
  221.      5,     0,     5,     0,     2,     1,     1,     1,     3,     1,
  222.      1,     4,     0,     0,     3,     2,     2,     1,     2,     1,
  223.      1,     3,     3,     3,     0,     2,     1,     1,     2,     3,
  224.      2,     1,     3,     1,     2,     2,     1,     2,     2,     2,
  225.      6,     5,     4,     1,     1,     1,     3,     3,     1,     3,
  226.      4,     4,     2,     0,     2,     0
  227. };
  228.  
  229. static const short yydefact[] = {     2,
  230.      0,     0,     0,     5,     6,     7,     8,    13,     0,    14,
  231.      0,     0,    11,    10,     0,    21,    49,    46,    20,     0,
  232.      0,    44,    56,     0,    54,     0,     0,    18,    32,     0,
  233.     34,    37,    45,     0,     3,    17,    27,     0,     0,     0,
  234.      0,     0,    54,     0,    12,    19,     0,    16,    31,     0,
  235.     35,    29,    36,    38,    39,    40,     0,     9,    23,    22,
  236.      0,    28,    26,    55,    47,    48,     0,    53,    50,    15,
  237.     33,    30,     0,    24,    51,     0,     0,    43,    52,     0,
  238.     42,    41,     0,     0,     0
  239. };
  240.  
  241. static const short yydefgoto[] = {    83,
  242.      1,     3,     8,     9,    15,    10,    12,    26,    27,    39,
  243.     40,    63,    28,    29,    30,    31,    32,    33,    44,    41
  244. };
  245.  
  246. static const short yypact[] = {-32768,
  247.     61,    -2,    64,-32768,-32768,-32768,-32768,-32768,    13,-32768,
  248.     34,     1,-32768,-32768,    30,-32768,-32768,-32768,-32768,    21,
  249.     48,-32768,-32768,    21,    31,    33,    26,-32768,    54,    21,
  250.     21,    38,-32768,    47,-32768,-32768,-32768,    43,     5,    56,
  251.     15,   -11,-32768,     2,-32768,-32768,    21,-32768,-32768,    21,
  252. -32768,    57,    38,-32768,-32768,-32768,    59,-32768,-32768,-32768,
  253.     56,-32768,-32768,-32768,-32768,-32768,     4,    46,-32768,-32768,
  254.     21,-32768,    -8,-32768,-32768,    75,    -1,-32768,-32768,    55,
  255. -32768,-32768,    80,    81,-32768
  256. };
  257.  
  258. static const short yypgoto[] = {-32768,
  259. -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
  260. -32768,    22,   -14,    -5,-32768,    32,   -31,-32768,    41,-32768
  261. };
  262.  
  263.  
  264. #define    YYLAST        84
  265.  
  266.  
  267. static const short yytable[] = {    53,
  268.     -1,    16,    80,    17,    68,    36,    68,    50,    77,     4,
  269.     18,    19,    48,    20,    21,    78,    66,    64,    42,    60,
  270.     11,    61,    81,    17,    52,    22,    23,    24,    17,    25,
  271.     18,    69,    70,    75,    13,    18,    46,    34,    47,    53,
  272.     65,    35,    14,    43,    45,    22,    23,    24,    37,    25,
  273.     22,    23,    24,    54,    25,    58,   -25,    59,    55,    56,
  274.     57,     2,    73,    38,    62,    -4,    -4,    -4,     5,     6,
  275.      7,    49,    50,    51,    72,    50,    76,    79,    82,    84,
  276.     85,    71,    74,    67
  277. };
  278.  
  279. static const short yycheck[] = {    31,
  280.      0,     1,     4,     3,     3,    20,     3,    19,    17,    12,
  281.     10,    11,    27,    13,    14,    24,    28,     3,    24,    15,
  282.      8,    17,    24,     3,    30,    25,    26,    27,     3,    29,
  283.     10,    30,    47,    30,     1,    10,    11,     8,    13,    71,
  284.     26,    12,     9,    13,    12,    25,    26,    27,     1,    29,
  285.     25,    26,    27,    16,    29,     9,     9,    15,    21,    22,
  286.     23,     1,     4,    16,     9,     5,     6,     7,     5,     6,
  287.      7,    18,    19,    20,    18,    19,    31,     3,    24,     0,
  288.      0,    50,    61,    43
  289. };
  290. /* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
  291. #line 3 "bison.simple"
  292.  
  293. /* Skeleton output parser for bison,
  294.    Copyright (C) 1984, 1989, 1990 Bob Corbett and Richard Stallman
  295.  
  296.    This program is free software; you can redistribute it and/or modify
  297.    it under the terms of the GNU General Public License as published by
  298.    the Free Software Foundation; either version 1, or (at your option)
  299.    any later version.
  300.  
  301.    This program is distributed in the hope that it will be useful,
  302.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  303.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  304.    GNU General Public License for more details.
  305.  
  306.    You should have received a copy of the GNU General Public License
  307.    along with this program; if not, write to the Free Software
  308.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  309.  
  310.  
  311. #ifndef alloca
  312. #ifdef __GNUC__
  313. #define alloca __builtin_alloca
  314. #else /* not GNU C.  */
  315. #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi)
  316. #include <alloca.h>
  317. #else /* not sparc */
  318. #if defined (MSDOS) && !defined (__TURBOC__)
  319. #include <malloc.h>
  320. #else /* not MSDOS, or __TURBOC__ */
  321. #if defined(_AIX)
  322. #include <malloc.h>
  323.  #pragma alloca
  324. #else /* not MSDOS, __TURBOC__, or _AIX */
  325. #ifdef __hpux
  326. #ifdef __cplusplus
  327. extern "C" {
  328. void *alloca (unsigned int);
  329. };
  330. #else /* not __cplusplus */
  331. void *alloca (unsigned int);
  332. #endif /* not __cplusplus */
  333. #endif /* __hpux */
  334. #endif /* not _AIX */
  335. #endif /* not MSDOS, or __TURBOC__ */
  336. #endif /* not sparc.  */
  337. #endif /* not GNU C.  */
  338. #endif /* alloca not defined.  */
  339.  
  340. /* This is the parser code that is written into each bison parser
  341.   when the %semantic_parser declaration is not specified in the grammar.
  342.   It was written by Richard Stallman by simplifying the hairy parser
  343.   used when %semantic_parser is specified.  */
  344.  
  345. /* Note: there must be only one dollar sign in this file.
  346.    It is replaced by the list of actions, each action
  347.    as one case of the switch.  */
  348.  
  349.  
  350.  
  351.  
  352.  
  353. #ifdef AMIGA
  354. /* Allocate and clear storage for bison,
  355.    Copyright (C) 1984, 1989 Free Software Foundation, Inc.
  356. */
  357.  
  358.  
  359. #include <stdio.h>
  360.  
  361. #define done(s) exit(s)     /* AMIGA exit*/
  362.  
  363. /*extern char *calloc();
  364. extern void done();
  365. extern char *program_name;      Not extern in this file (AMIGA) */
  366.  
  367. char *mallocate(register unsigned n)
  368. {
  369.   register char *block;
  370.  
  371.   /* Avoid uncertainty about what an arg of 0 will do.  */
  372.   if (n == 0)
  373.     n = 1;
  374.   block = (char *)calloc(n,1);
  375.   if (block == NULL)
  376.     {
  377.       fprintf(stderr, "%s: memory exhausted\n"/*, program_name Not AMIGA COMPATIBLE */);
  378.       done(1);
  379.     }
  380.  
  381.   return (block);
  382. }
  383.  
  384. /* This name is used by alloca.c.  */
  385.  
  386. char *xmalloc (unsigned int n)
  387. {
  388.   return mallocate (n);
  389. }
  390.  
  391. /*
  392.     alloca -- (mostly) portable public-domain implementation -- D A Gwyn
  393.  
  394.     93/3/31         jimb
  395.        Use xfree instead of free.
  396.     86/05/30    rms
  397.        include config.h, since on VMS it renames some symbols.
  398.        Use xmalloc instead of malloc.
  399.  
  400. */
  401. #ifndef lint
  402. static char    SCCSid[] = "@(#)alloca.c    1.1";    /* for the "what" utility */
  403. #endif
  404.  
  405. #ifdef HAVE_CONFIG_H
  406. #include "config.h"
  407. #endif
  408.  
  409. #ifdef emacs
  410. #ifdef static
  411. /* actually, only want this if static is defined as ""
  412.    -- this is for usg, in which emacs must undefine static
  413.    in order to make unexec workable
  414.    */
  415. #ifndef STACK_DIRECTION
  416. you
  417. lose
  418. -- must know STACK_DIRECTION at compile-time
  419. #endif /* STACK_DIRECTION undefined */
  420. #endif /* static */
  421. #endif /* emacs */
  422.  
  423. #ifdef emacs
  424. #define free xfree
  425. #endif
  426.  
  427. #ifndef alloca  /* If compiling with GCC, this file's not needed.  */
  428.  
  429. #ifdef __STDC__
  430. typedef void    *pointer;        /* generic pointer type */
  431. #else
  432. typedef char    *pointer;        /* generic pointer type */
  433. #endif
  434.  
  435. /* #define    NULL    0    null pointer constant (AMIGA has defined in <stdio.h>*/
  436.  
  437. /*extern pointer    xmalloc ();   Already included (AMIGA)*/
  438.  
  439. /*
  440.     Define STACK_DIRECTION if you know the direction of stack
  441.     growth for your system; otherwise it will be automatically
  442.     deduced at run-time.
  443.  
  444.     STACK_DIRECTION > 0 => grows toward higher addresses
  445.     STACK_DIRECTION < 0 => grows toward lower addresses
  446.     STACK_DIRECTION = 0 => direction of growth unknown
  447. */
  448.  
  449. #ifndef STACK_DIRECTION
  450. #define    STACK_DIRECTION    0        /* direction unknown */
  451. #endif
  452.  
  453. #if STACK_DIRECTION != 0
  454.  
  455. #define    STACK_DIR    STACK_DIRECTION    /* known at compile-time */
  456.  
  457. #else    /* STACK_DIRECTION == 0; need run-time code */
  458.  
  459. static int    stack_dir;        /* 1 or -1 once known */
  460. #define    STACK_DIR    stack_dir
  461.  
  462. static void
  463. find_stack_direction (/* void */)
  464. {
  465.   static char    *addr = NULL;    /* address of first
  466.                    `dummy', once known */
  467.   auto char    dummy;        /* to get stack address */
  468.  
  469.   if (addr == NULL)
  470.     {                /* initial entry */
  471.       addr = &dummy;
  472.  
  473.       find_stack_direction ();    /* recurse once */
  474.     }
  475.   else                /* second entry */
  476.     if (&dummy > addr)
  477.       stack_dir = 1;        /* stack grew upward */
  478.     else
  479.       stack_dir = -1;        /* stack grew downward */
  480. }
  481.  
  482. #endif    /* STACK_DIRECTION == 0 */
  483.  
  484. /*
  485.     An "alloca header" is used to:
  486.     (a) chain together all alloca'ed blocks;
  487.     (b) keep track of stack depth.
  488.  
  489.     It is very important that sizeof (header) agree with malloc
  490.     alignment chunk size.  The following default should work okay.
  491. */
  492.  
  493. #ifndef    ALIGN_SIZE
  494. #define    ALIGN_SIZE    sizeof (double)
  495. #endif
  496.  
  497. typedef union hdr
  498. {
  499.   char    align[ALIGN_SIZE];    /* to force sizeof (header) */
  500.   struct
  501.     {
  502.       union hdr *next;        /* for chaining headers */
  503.       char *deep;        /* for stack depth measure */
  504.     } h;
  505. } header;
  506.  
  507. /*
  508.     alloca ( size ) returns a pointer to at least `size' bytes of
  509.     storage which will be automatically reclaimed upon exit from
  510.     the procedure that called alloca.  Originally, this space
  511.     was supposed to be taken from the current stack frame of the
  512.     caller, but that method cannot be made to work for some
  513.     implementations of C, for example under Gould's UTX/32.
  514. */
  515.  
  516. static header *last_alloca_header = NULL; /* -> last alloca header */
  517.  
  518. pointer alloca (unsigned size)            /* returns pointer to storage */
  519.                             /* # bytes to allocate */
  520. {
  521.   auto char    probe;        /* probes stack depth: */
  522.   register char    *depth = &probe;
  523.  
  524. #if STACK_DIRECTION == 0
  525.   if (STACK_DIR == 0)        /* unknown growth direction */
  526.     find_stack_direction ();
  527. #endif
  528.  
  529.                 /* Reclaim garbage, defined as all alloca'ed storage that
  530.                    was allocated from deeper in the stack than currently. */
  531.  
  532.   {
  533.     register header    *hp;    /* traverses linked list */
  534.  
  535.     for (hp = last_alloca_header; hp != NULL;)
  536.       if ((STACK_DIR > 0 && hp->h.deep > depth)
  537.       || (STACK_DIR < 0 && hp->h.deep < depth))
  538.     {
  539.       register header    *np = hp->h.next;
  540.  
  541.       free ((pointer) hp);    /* collect garbage */
  542.  
  543.       hp = np;        /* -> next header */
  544.     }
  545.       else
  546.     break;            /* rest are not deeper */
  547.  
  548.     last_alloca_header = hp;    /* -> last valid storage */
  549.   }
  550.  
  551.   if (size == 0)
  552.     return NULL;        /* no allocation required */
  553.  
  554.   /* Allocate combined header + user data storage. */
  555.  
  556.   {
  557.     register pointer    new = xmalloc (sizeof (header) + size);
  558.     /* address of header */
  559.  
  560.     ((header *)new)->h.next = last_alloca_header;
  561.     ((header *)new)->h.deep = depth;
  562.  
  563.     last_alloca_header = (header *)new;
  564.  
  565.     /* User storage begins just after header. */
  566.  
  567.     return (pointer)((char *)new + sizeof (header));
  568.   }
  569. }
  570.  
  571. #endif /* no alloca */
  572. #endif /* AMIGA */
  573.  
  574.  
  575.  
  576.  
  577.  
  578.  
  579. #define yyerrok        (yyerrstatus = 0)
  580. #define yyclearin    (yychar = YYEMPTY)
  581. #define YYEMPTY        -2
  582. #define YYEOF        0
  583. #define YYACCEPT    return(0)
  584. #define YYABORT     return(1)
  585. #define YYERROR        goto yyerrlab1
  586. /* Like YYERROR except do call yyerror.
  587.    This remains here temporarily to ease the
  588.    transition to the new meaning of YYERROR, for GCC.
  589.    Once GCC version 2 has supplanted version 1, this can go.  */
  590. #define YYFAIL        goto yyerrlab
  591. #define YYRECOVERING()  (!!yyerrstatus)
  592. #define YYBACKUP(token, value) \
  593. do                                \
  594.   if (yychar == YYEMPTY && yylen == 1)                \
  595.     { yychar = (token), yylval = (value);            \
  596.       yychar1 = YYTRANSLATE (yychar);                \
  597.       YYPOPSTACK;                        \
  598.       goto yybackup;                        \
  599.     }                                \
  600.   else                                \
  601.     { yyerror ("syntax error: cannot back up"); YYERROR; }    \
  602. while (0)
  603.  
  604. #define YYTERROR    1
  605. #define YYERRCODE    256
  606.  
  607. #ifndef YYPURE
  608. #define YYLEX        yylex()
  609. #endif
  610.  
  611. #ifdef YYPURE
  612. #ifdef YYLSP_NEEDED
  613. #define YYLEX        yylex(&yylval, &yylloc)
  614. #else
  615. #define YYLEX        yylex(&yylval)
  616. #endif
  617. #endif
  618.  
  619. /* If nonreentrant, generate the variables here */
  620.  
  621. #ifndef YYPURE
  622.  
  623. int    yychar;            /*  the lookahead symbol        */
  624. YYSTYPE    yylval;            /*  the semantic value of the        */
  625.                 /*  lookahead symbol            */
  626.  
  627. #ifdef YYLSP_NEEDED
  628. YYLTYPE yylloc;            /*  location data for the lookahead    */
  629.                 /*  symbol                */
  630. #endif
  631.  
  632. int yynerrs;            /*  number of parse errors so far       */
  633. #endif  /* not YYPURE */
  634.  
  635. #if YYDEBUG != 0
  636. int yydebug;            /*  nonzero means print parse trace    */
  637. /* Since this is uninitialized, it does not stop multiple parsers
  638.    from coexisting.  */
  639. #endif
  640.  
  641. /*  YYINITDEPTH indicates the initial size of the parser's stacks    */
  642.  
  643. #ifndef    YYINITDEPTH
  644. #define YYINITDEPTH 200
  645. #endif
  646.  
  647. /*  YYMAXDEPTH is the maximum size the stacks can grow to
  648.     (effective only if the built-in stack extension method is used).  */
  649.  
  650. #if YYMAXDEPTH == 0
  651. #undef YYMAXDEPTH
  652. #endif
  653.  
  654. #ifndef YYMAXDEPTH
  655. #define YYMAXDEPTH 10000
  656. #endif
  657.  
  658. /* Prevent warning if -Wstrict-prototypes.  */
  659. #ifdef __GNUC__
  660. int yyparse (void);
  661. #endif
  662.  
  663. #if __GNUC__ > 1        /* GNU C and GNU C++ define this.  */
  664. #define __yy_bcopy(FROM,TO,COUNT)    __builtin_memcpy(TO,FROM,COUNT)
  665. #else                /* not GNU C or C++ */
  666. #ifndef __cplusplus
  667.  
  668. /* This is the most reliable way to avoid incompatibilities
  669.    in available built-in functions on various systems.  */
  670. static void
  671. __yy_bcopy (from, to, count)
  672.      char *from;
  673.      char *to;
  674.      int count;
  675. {
  676.   register char *f = from;
  677.   register char *t = to;
  678.   register int i = count;
  679.  
  680.   while (i-- > 0)
  681.     *t++ = *f++;
  682. }
  683.  
  684. #else /* __cplusplus */
  685.  
  686. /* This is the most reliable way to avoid incompatibilities
  687.    in available built-in functions on various systems.  */
  688. static void
  689. __yy_bcopy (char *from, char *to, int count)
  690. {
  691.   register char *f = from;
  692.   register char *t = to;
  693.   register int i = count;
  694.  
  695.   while (i-- > 0)
  696.     *t++ = *f++;
  697. }
  698.  
  699. #endif
  700. #endif
  701.  
  702. #line 184 "bison.simple"
  703. int
  704. yyparse()
  705. {
  706.   register int yystate;
  707.   register int yyn;
  708.   register short *yyssp;
  709.   register YYSTYPE *yyvsp;
  710.   int yyerrstatus;    /*  number of tokens to shift before error messages enabled */
  711.   int yychar1;        /*  lookahead token as an internal (translated) token number */
  712.  
  713.   short    yyssa[YYINITDEPTH];    /*  the state stack            */
  714.   YYSTYPE yyvsa[YYINITDEPTH];    /*  the semantic value stack        */
  715.  
  716.   short *yyss = yyssa;        /*  refer to the stacks thru separate pointers */
  717.   YYSTYPE *yyvs = yyvsa;    /*  to allow yyoverflow to reallocate them elsewhere */
  718.  
  719. #ifdef YYLSP_NEEDED
  720.   YYLTYPE yylsa[YYINITDEPTH];    /*  the location stack            */
  721.   YYLTYPE *yyls = yylsa;
  722.   YYLTYPE *yylsp;
  723.  
  724. #define YYPOPSTACK   (yyvsp--, yyssp--, yylsp--)
  725. #else
  726. #define YYPOPSTACK   (yyvsp--, yyssp--)
  727. #endif
  728.  
  729.   int yystacksize = YYINITDEPTH;
  730.  
  731. #ifdef YYPURE
  732.   int yychar;
  733.   YYSTYPE yylval;
  734.   int yynerrs;
  735. #ifdef YYLSP_NEEDED
  736.   YYLTYPE yylloc;
  737. #endif
  738. #endif
  739.  
  740.   YYSTYPE yyval;        /*  the variable used to return        */
  741.                 /*  semantic values from the action    */
  742.                 /*  routines                */
  743.  
  744.   int yylen;
  745.  
  746. #if YYDEBUG != 0
  747.   if (yydebug)
  748.     fprintf(stderr, "Starting parse\n");
  749. #endif
  750.  
  751.   yystate = 0;
  752.   yyerrstatus = 0;
  753.   yynerrs = 0;
  754.   yychar = YYEMPTY;        /* Cause a token to be read.  */
  755.  
  756.   /* Initialize stack pointers.
  757.      Waste one element of value and location stack
  758.      so that they stay on the same level as the state stack.
  759.      The wasted elements are never initialized.  */
  760.  
  761.   yyssp = yyss - 1;
  762.   yyvsp = yyvs;
  763. #ifdef YYLSP_NEEDED
  764.   yylsp = yyls;
  765. #endif
  766.  
  767. /* Push a new state, which is found in  yystate  .  */
  768. /* In all cases, when you get here, the value and location stacks
  769.    have just been pushed. so pushing a state here evens the stacks.  */
  770. yynewstate:
  771.  
  772.   *++yyssp = yystate;
  773.  
  774.   if (yyssp >= yyss + yystacksize - 1)
  775.     {
  776.       /* Give user a chance to reallocate the stack */
  777.       /* Use copies of these so that the &'s don't force the real ones into memory. */
  778.       YYSTYPE *yyvs1 = yyvs;
  779.       short *yyss1 = yyss;
  780. #ifdef YYLSP_NEEDED
  781.       YYLTYPE *yyls1 = yyls;
  782. #endif
  783.  
  784.       /* Get the current used size of the three stacks, in elements.  */
  785.       int size = yyssp - yyss + 1;
  786.  
  787. #ifdef yyoverflow
  788.       /* Each stack pointer address is followed by the size of
  789.      the data in use in that stack, in bytes.  */
  790.       yyoverflow("parser stack overflow",
  791.          &yyss1, size * sizeof (*yyssp),
  792.          &yyvs1, size * sizeof (*yyvsp),
  793. #ifdef YYLSP_NEEDED
  794.          &yyls1, size * sizeof (*yylsp),
  795. #endif
  796.          &yystacksize);
  797.  
  798.       yyss = yyss1; yyvs = yyvs1;
  799. #ifdef YYLSP_NEEDED
  800.       yyls = yyls1;
  801. #endif
  802. #else /* no yyoverflow */
  803.       /* Extend the stack our own way.  */
  804.       if (yystacksize >= YYMAXDEPTH)
  805.     {
  806.       yyerror("parser stack overflow");
  807.       return 2;
  808.     }
  809.       yystacksize *= 2;
  810.       if (yystacksize > YYMAXDEPTH)
  811.     yystacksize = YYMAXDEPTH;
  812.       yyss = (short *) alloca (yystacksize * sizeof (*yyssp));
  813.       __yy_bcopy ((char *)yyss1, (char *)yyss, size * sizeof (*yyssp));
  814.       yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp));
  815.       __yy_bcopy ((char *)yyvs1, (char *)yyvs, size * sizeof (*yyvsp));
  816. #ifdef YYLSP_NEEDED
  817.       yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp));
  818.       __yy_bcopy ((char *)yyls1, (char *)yyls, size * sizeof (*yylsp));
  819. #endif
  820. #endif /* no yyoverflow */
  821.  
  822.       yyssp = yyss + size - 1;
  823.       yyvsp = yyvs + size - 1;
  824. #ifdef YYLSP_NEEDED
  825.       yylsp = yyls + size - 1;
  826. #endif
  827.  
  828. #if YYDEBUG != 0
  829.       if (yydebug)
  830.     fprintf(stderr, "Stack size increased to %d\n", yystacksize);
  831. #endif
  832.  
  833.       if (yyssp >= yyss + yystacksize - 1)
  834.     YYABORT;
  835.     }
  836.  
  837. #if YYDEBUG != 0
  838.   if (yydebug)
  839.     fprintf(stderr, "Entering state %d\n", yystate);
  840. #endif
  841.  
  842.   goto yybackup;
  843.  yybackup:
  844.  
  845. /* Do appropriate processing given the current state.  */
  846. /* Read a lookahead token if we need one and don't already have one.  */
  847. /* yyresume: */
  848.  
  849.   /* First try to decide what to do without reference to lookahead token.  */
  850.  
  851.   yyn = yypact[yystate];
  852.   if (yyn == YYFLAG)
  853.     goto yydefault;
  854.  
  855.   /* Not known => get a lookahead token if don't already have one.  */
  856.  
  857.   /* yychar is either YYEMPTY or YYEOF
  858.      or a valid token in external form.  */
  859.  
  860.   if (yychar == YYEMPTY)
  861.     {
  862. #if YYDEBUG != 0
  863.       if (yydebug)
  864.     fprintf(stderr, "Reading a token: ");
  865. #endif
  866.       yychar = YYLEX;
  867.     }
  868.  
  869.   /* Convert token to internal form (in yychar1) for indexing tables with */
  870.  
  871.   if (yychar <= 0)        /* This means end of input. */
  872.     {
  873.       yychar1 = 0;
  874.       yychar = YYEOF;        /* Don't call YYLEX any more */
  875.  
  876. #if YYDEBUG != 0
  877.       if (yydebug)
  878.     fprintf(stderr, "Now at end of input.\n");
  879. #endif
  880.     }
  881.   else
  882.     {
  883.       yychar1 = YYTRANSLATE(yychar);
  884.  
  885. #if YYDEBUG != 0
  886.       if (yydebug)
  887.     {
  888.       fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
  889.       /* Give the individual parser a way to print the precise meaning
  890.          of a token, for further debugging info.  */
  891. #ifdef YYPRINT
  892.       YYPRINT (stderr, yychar, yylval);
  893. #endif
  894.       fprintf (stderr, ")\n");
  895.     }
  896. #endif
  897.     }
  898.  
  899.   yyn += yychar1;
  900.   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
  901.     goto yydefault;
  902.  
  903.   yyn = yytable[yyn];
  904.  
  905.   /* yyn is what to do for this token type in this state.
  906.      Negative => reduce, -yyn is rule number.
  907.      Positive => shift, yyn is new state.
  908.        New state is final state => don't bother to shift,
  909.        just return success.
  910.      0, or most negative number => error.  */
  911.  
  912.   if (yyn < 0)
  913.     {
  914.       if (yyn == YYFLAG)
  915.     goto yyerrlab;
  916.       yyn = -yyn;
  917.       goto yyreduce;
  918.     }
  919.   else if (yyn == 0)
  920.     goto yyerrlab;
  921.  
  922.   if (yyn == YYFINAL)
  923.     YYACCEPT;
  924.  
  925.   /* Shift the lookahead token.  */
  926.  
  927. #if YYDEBUG != 0
  928.   if (yydebug)
  929.     fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
  930. #endif
  931.  
  932.   /* Discard the token being shifted unless it is eof.  */
  933.   if (yychar != YYEOF)
  934.     yychar = YYEMPTY;
  935.  
  936.   *++yyvsp = yylval;
  937. #ifdef YYLSP_NEEDED
  938.   *++yylsp = yylloc;
  939. #endif
  940.  
  941.   /* count tokens shifted since error; after three, turn off error status.  */
  942.   if (yyerrstatus) yyerrstatus--;
  943.  
  944.   yystate = yyn;
  945.   goto yynewstate;
  946.  
  947. /* Do the default action for the current state.  */
  948. yydefault:
  949.  
  950.   yyn = yydefact[yystate];
  951.   if (yyn == 0)
  952.     goto yyerrlab;
  953.  
  954. /* Do a reduction.  yyn is the number of a rule to reduce with.  */
  955. yyreduce:
  956.   yylen = yyr2[yyn];
  957.   yyval = yyvsp[1-yylen]; /* implement default value of the action */
  958.  
  959. #if YYDEBUG != 0
  960.   if (yydebug)
  961.     {
  962.       int i;
  963.  
  964.       fprintf (stderr, "Reducing via rule %d (line %d), ",
  965.            yyn, yyrline[yyn]);
  966.  
  967.       /* Print the symbols being reduced, and their result.  */
  968.       for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
  969.     fprintf (stderr, "%s ", yytname[yyrhs[i]]);
  970.       fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
  971.     }
  972. #endif
  973.  
  974.  
  975.   switch (yyn) {
  976.  
  977. case 1:
  978. #line 85 "parse.y"
  979. { /* add default rule */
  980.             int def_rule;
  981.  
  982.             pat = cclinit();
  983.             cclnegate( pat );
  984.  
  985.             def_rule = mkstate( -pat );
  986.  
  987.             /* Remember the number of the default rule so we
  988.              * don't generate "can't match" warnings for it.
  989.              */
  990.             default_rule = num_rules;
  991.  
  992.             finish_rule( def_rule, false, 0, 0 );
  993.  
  994.             for ( i = 1; i <= lastsc; ++i )
  995.                 scset[i] = mkbranch( scset[i], def_rule );
  996.  
  997.             if ( spprdflt )
  998.                 add_action(
  999.                 "YY_FATAL_ERROR( \"flex scanner jammed\" )" );
  1000.             else
  1001.                 add_action( "ECHO" );
  1002.  
  1003.             add_action( ";\n\tYY_BREAK\n" );
  1004.             ;
  1005.     break;}
  1006. case 2:
  1007. #line 114 "parse.y"
  1008. { /* initialize for processing rules */
  1009.  
  1010.             /* Create default DFA start condition. */
  1011.             scinstal( "INITIAL", false );
  1012.  
  1013.             /* Initially, the start condition scoping is
  1014.              * "no start conditions active".
  1015.              */
  1016.             actvp = 0;
  1017.             ;
  1018.     break;}
  1019. case 5:
  1020. #line 129 "parse.y"
  1021. { synerr( "unknown error processing section 1" ); ;
  1022.     break;}
  1023. case 6:
  1024. #line 133 "parse.y"
  1025. {
  1026.             /* We now know how many start conditions there
  1027.              * are, so create the "activity" map indicating
  1028.              * which conditions are active.
  1029.              */
  1030.             active_ss = allocate_integer_array( lastsc + 1 );
  1031.  
  1032.             for ( i = 1; i <= lastsc; ++i )
  1033.                 active_ss[i] = 0;
  1034.             ;
  1035.     break;}
  1036. case 7:
  1037. #line 146 "parse.y"
  1038. { xcluflg = false; ;
  1039.     break;}
  1040. case 8:
  1041. #line 149 "parse.y"
  1042. { xcluflg = true; ;
  1043.     break;}
  1044. case 9:
  1045. #line 153 "parse.y"
  1046. { scinstal( nmstr, xcluflg ); ;
  1047.     break;}
  1048. case 10:
  1049. #line 156 "parse.y"
  1050. { scinstal( nmstr, xcluflg ); ;
  1051.     break;}
  1052. case 11:
  1053. #line 159 "parse.y"
  1054. { synerr( "bad start condition list" ); ;
  1055.     break;}
  1056. case 14:
  1057. #line 167 "parse.y"
  1058. {
  1059.             /* Initialize for a parse of one rule. */
  1060.             trlcontxt = variable_trail_rule = varlength = false;
  1061.             trailcnt = headcnt = rulelen = 0;
  1062.             current_state_type = STATE_NORMAL;
  1063.             previous_continued_action = continued_action;
  1064.             new_rule();
  1065.             ;
  1066.     break;}
  1067. case 15:
  1068. #line 178 "parse.y"
  1069. {
  1070.             pat = yyvsp[0];
  1071.             finish_rule( pat, variable_trail_rule,
  1072.                 headcnt, trailcnt );
  1073.  
  1074.             for ( i = 1; i <= actvp; ++i )
  1075.                 scbol[actvsc[i]] =
  1076.                     mkbranch( scbol[actvsc[i]], pat );
  1077.  
  1078.             if ( ! bol_needed )
  1079.                 {
  1080.                 bol_needed = true;
  1081.  
  1082.                 if ( performance_report > 1 )
  1083.                     pinpoint_message( 
  1084.             "'^' operator results in sub-optimal performance" );
  1085.                 }
  1086.             ;
  1087.     break;}
  1088. case 16:
  1089. #line 198 "parse.y"
  1090. {
  1091.             pat = yyvsp[0];
  1092.             finish_rule( pat, variable_trail_rule,
  1093.                 headcnt, trailcnt );
  1094.  
  1095.             for ( i = 1; i <= actvp; ++i )
  1096.                 scset[actvsc[i]] =
  1097.                     mkbranch( scset[actvsc[i]], pat );
  1098.             ;
  1099.     break;}
  1100. case 17:
  1101. #line 209 "parse.y"
  1102. {
  1103.             pat = yyvsp[0];
  1104.             finish_rule( pat, variable_trail_rule,
  1105.                 headcnt, trailcnt );
  1106.  
  1107.             /* Add to all non-exclusive start conditions,
  1108.              * including the default (0) start condition.
  1109.              */
  1110.  
  1111.             for ( i = 1; i <= lastsc; ++i )
  1112.                 if ( ! scxclu[i] )
  1113.                     scbol[i] = mkbranch( scbol[i], pat );
  1114.  
  1115.             if ( ! bol_needed )
  1116.                 {
  1117.                 bol_needed = true;
  1118.  
  1119.                 if ( performance_report > 1 )
  1120.                     pinpoint_message(
  1121.             "'^' operator results in sub-optimal performance" );
  1122.                 }
  1123.             ;
  1124.     break;}
  1125. case 18:
  1126. #line 233 "parse.y"
  1127. {
  1128.             pat = yyvsp[0];
  1129.             finish_rule( pat, variable_trail_rule,
  1130.                 headcnt, trailcnt );
  1131.  
  1132.             for ( i = 1; i <= lastsc; ++i )
  1133.                 if ( ! scxclu[i] )
  1134.                     scset[i] = mkbranch( scset[i], pat );
  1135.             ;
  1136.     break;}
  1137. case 19:
  1138. #line 244 "parse.y"
  1139. { build_eof_action(); ;
  1140.     break;}
  1141. case 20:
  1142. #line 247 "parse.y"
  1143. {
  1144.             /* This EOF applies to all start conditions
  1145.              * which don't already have EOF actions.
  1146.              */
  1147.             actvp = 0;
  1148.  
  1149.             for ( i = 1; i <= lastsc; ++i )
  1150.                 if ( ! sceof[i] )
  1151.                     actvsc[++actvp] = i;
  1152.  
  1153.             if ( actvp == 0 )
  1154.                 warn(
  1155.             "all start conditions already have <<EOF>> rules" );
  1156.  
  1157.             else
  1158.                 build_eof_action();
  1159.             ;
  1160.     break;}
  1161. case 21:
  1162. #line 266 "parse.y"
  1163. { synerr( "unrecognized rule" ); ;
  1164.     break;}
  1165. case 23:
  1166. #line 272 "parse.y"
  1167. {
  1168.             actvp = 0;
  1169.  
  1170.             for ( i = 1; i <= lastsc; ++i )
  1171.                 actvsc[++actvp] = i;
  1172.             ;
  1173.     break;}
  1174. case 25:
  1175. #line 282 "parse.y"
  1176. { actvp = 0; ;
  1177.     break;}
  1178. case 27:
  1179. #line 285 "parse.y"
  1180. { synerr( "bad start condition list" ); ;
  1181.     break;}
  1182. case 28:
  1183. #line 289 "parse.y"
  1184. {
  1185.             if ( (scnum = sclookup( nmstr )) == 0 )
  1186.                 format_pinpoint_message(
  1187.                     "undeclared start condition %s",
  1188.                     nmstr );
  1189.             else
  1190.                 {
  1191.                 if ( ++actvp >= current_max_scs )
  1192.                     /* Some bozo has included multiple
  1193.                      * instances of start condition names.
  1194.                      */
  1195.                     pinpoint_message(
  1196.                 "too many start conditions in <> construct!" );
  1197.  
  1198.                 else
  1199.                     actvsc[actvp] = scnum;
  1200.                 }
  1201.             ;
  1202.     break;}
  1203. case 29:
  1204. #line 310 "parse.y"
  1205. {
  1206.             if ( transchar[lastst[yyvsp[0]]] != SYM_EPSILON )
  1207.                 /* Provide final transition \now/ so it
  1208.                  * will be marked as a trailing context
  1209.                  * state.
  1210.                  */
  1211.                 yyvsp[0] = link_machines( yyvsp[0],
  1212.                         mkstate( SYM_EPSILON ) );
  1213.  
  1214.             mark_beginning_as_normal( yyvsp[0] );
  1215.             current_state_type = STATE_NORMAL;
  1216.  
  1217.             if ( previous_continued_action )
  1218.                 {
  1219.                 /* We need to treat this as variable trailing
  1220.                  * context so that the backup does not happen
  1221.                  * in the action but before the action switch
  1222.                  * statement.  If the backup happens in the
  1223.                  * action, then the rules "falling into" this
  1224.                  * one's action will *also* do the backup,
  1225.                  * erroneously.
  1226.                  */
  1227.                 if ( ! varlength || headcnt != 0 )
  1228.                     warn(
  1229.         "trailing context made variable due to preceding '|' action" );
  1230.  
  1231.                 /* Mark as variable. */
  1232.                 varlength = true;
  1233.                 headcnt = 0;
  1234.                 }
  1235.  
  1236.             if ( lex_compat || (varlength && headcnt == 0) )
  1237.                 { /* variable trailing context rule */
  1238.                 /* Mark the first part of the rule as the
  1239.                  * accepting "head" part of a trailing
  1240.                  * context rule.
  1241.                  *
  1242.                  * By the way, we didn't do this at the
  1243.                  * beginning of this production because back
  1244.                  * then current_state_type was set up for a
  1245.                  * trail rule, and add_accept() can create
  1246.                  * a new state ...
  1247.                  */
  1248.                 add_accept( yyvsp[-1],
  1249.                     num_rules | YY_TRAILING_HEAD_MASK );
  1250.                 variable_trail_rule = true;
  1251.                 }
  1252.             
  1253.             else
  1254.                 trailcnt = rulelen;
  1255.  
  1256.             yyval = link_machines( yyvsp[-1], yyvsp[0] );
  1257.             ;
  1258.     break;}
  1259. case 30:
  1260. #line 365 "parse.y"
  1261. { synerr( "trailing context used twice" ); ;
  1262.     break;}
  1263. case 31:
  1264. #line 368 "parse.y"
  1265. {
  1266.             headcnt = 0;
  1267.             trailcnt = 1;
  1268.             rulelen = 1;
  1269.             varlength = false;
  1270.  
  1271.             current_state_type = STATE_TRAILING_CONTEXT;
  1272.  
  1273.             if ( trlcontxt )
  1274.                 {
  1275.                 synerr( "trailing context used twice" );
  1276.                 yyval = mkstate( SYM_EPSILON );
  1277.                 }
  1278.  
  1279.             else if ( previous_continued_action )
  1280.                 {
  1281.                 /* See the comment in the rule for "re2 re"
  1282.                  * above.
  1283.                  */
  1284.                 warn(
  1285.         "trailing context made variable due to preceding '|' action" );
  1286.  
  1287.                 varlength = true;
  1288.                 }
  1289.  
  1290.             if ( lex_compat || varlength )
  1291.                 {
  1292.                 /* Again, see the comment in the rule for
  1293.                  * "re2 re" above.
  1294.                  */
  1295.                 add_accept( yyvsp[-1],
  1296.                     num_rules | YY_TRAILING_HEAD_MASK );
  1297.                 variable_trail_rule = true;
  1298.                 }
  1299.  
  1300.             trlcontxt = true;
  1301.  
  1302.             eps = mkstate( SYM_EPSILON );
  1303.             yyval = link_machines( yyvsp[-1],
  1304.                 link_machines( eps, mkstate( '\n' ) ) );
  1305.             ;
  1306.     break;}
  1307. case 32:
  1308. #line 411 "parse.y"
  1309. {
  1310.             yyval = yyvsp[0];
  1311.  
  1312.             if ( trlcontxt )
  1313.                 {
  1314.                 if ( lex_compat || (varlength && headcnt == 0) )
  1315.                     /* Both head and trail are
  1316.                      * variable-length.
  1317.                      */
  1318.                     variable_trail_rule = true;
  1319.                 else
  1320.                     trailcnt = rulelen;
  1321.                 }
  1322.             ;
  1323.     break;}
  1324. case 33:
  1325. #line 429 "parse.y"
  1326. {
  1327.             varlength = true;
  1328.             yyval = mkor( yyvsp[-2], yyvsp[0] );
  1329.             ;
  1330.     break;}
  1331. case 34:
  1332. #line 435 "parse.y"
  1333. { yyval = yyvsp[0]; ;
  1334.     break;}
  1335. case 35:
  1336. #line 440 "parse.y"
  1337. {
  1338.             /* This rule is written separately so the
  1339.              * reduction will occur before the trailing
  1340.              * series is parsed.
  1341.              */
  1342.  
  1343.             if ( trlcontxt )
  1344.                 synerr( "trailing context used twice" );
  1345.             else
  1346.                 trlcontxt = true;
  1347.  
  1348.             if ( varlength )
  1349.                 /* We hope the trailing context is
  1350.                  * fixed-length.
  1351.                  */
  1352.                 varlength = false;
  1353.             else
  1354.                 headcnt = rulelen;
  1355.  
  1356.             rulelen = 0;
  1357.  
  1358.             current_state_type = STATE_TRAILING_CONTEXT;
  1359.             yyval = yyvsp[-1];
  1360.             ;
  1361.     break;}
  1362. case 36:
  1363. #line 467 "parse.y"
  1364. {
  1365.             /* This is where concatenation of adjacent patterns
  1366.              * gets done.
  1367.              */
  1368.             yyval = link_machines( yyvsp[-1], yyvsp[0] );
  1369.             ;
  1370.     break;}
  1371. case 37:
  1372. #line 475 "parse.y"
  1373. { yyval = yyvsp[0]; ;
  1374.     break;}
  1375. case 38:
  1376. #line 479 "parse.y"
  1377. {
  1378.             varlength = true;
  1379.  
  1380.             yyval = mkclos( yyvsp[-1] );
  1381.             ;
  1382.     break;}
  1383. case 39:
  1384. #line 486 "parse.y"
  1385. {
  1386.             varlength = true;
  1387.             yyval = mkposcl( yyvsp[-1] );
  1388.             ;
  1389.     break;}
  1390. case 40:
  1391. #line 492 "parse.y"
  1392. {
  1393.             varlength = true;
  1394.             yyval = mkopt( yyvsp[-1] );
  1395.             ;
  1396.     break;}
  1397. case 41:
  1398. #line 498 "parse.y"
  1399. {
  1400.             varlength = true;
  1401.  
  1402.             if ( yyvsp[-3] > yyvsp[-1] || yyvsp[-3] < 0 )
  1403.                 {
  1404.                 synerr( "bad iteration values" );
  1405.                 yyval = yyvsp[-5];
  1406.                 }
  1407.             else
  1408.                 {
  1409.                 if ( yyvsp[-3] == 0 )
  1410.                     {
  1411.                     if ( yyvsp[-1] <= 0 )
  1412.                         {
  1413.                         synerr(
  1414.                         "bad iteration values" );
  1415.                         yyval = yyvsp[-5];
  1416.                         }
  1417.                     else
  1418.                         yyval = mkopt(
  1419.                             mkrep( yyvsp[-5], 1, yyvsp[-1] ) );
  1420.                     }
  1421.                 else
  1422.                     yyval = mkrep( yyvsp[-5], yyvsp[-3], yyvsp[-1] );
  1423.                 }
  1424.             ;
  1425.     break;}
  1426. case 42:
  1427. #line 526 "parse.y"
  1428. {
  1429.             varlength = true;
  1430.  
  1431.             if ( yyvsp[-2] <= 0 )
  1432.                 {
  1433.                 synerr( "iteration value must be positive" );
  1434.                 yyval = yyvsp[-4];
  1435.                 }
  1436.  
  1437.             else
  1438.                 yyval = mkrep( yyvsp[-4], yyvsp[-2], INFINITY );
  1439.             ;
  1440.     break;}
  1441. case 43:
  1442. #line 540 "parse.y"
  1443. {
  1444.             /* The singleton could be something like "(foo)",
  1445.              * in which case we have no idea what its length
  1446.              * is, so we punt here.
  1447.              */
  1448.             varlength = true;
  1449.  
  1450.             if ( yyvsp[-1] <= 0 )
  1451.                 {
  1452.                 synerr( "iteration value must be positive" );
  1453.                 yyval = yyvsp[-3];
  1454.                 }
  1455.  
  1456.             else
  1457.                 yyval = link_machines( yyvsp[-3],
  1458.                         copysingl( yyvsp[-3], yyvsp[-1] - 1 ) );
  1459.             ;
  1460.     break;}
  1461. case 44:
  1462. #line 559 "parse.y"
  1463. {
  1464.             if ( ! madeany )
  1465.                 {
  1466.                 /* Create the '.' character class. */
  1467.                 anyccl = cclinit();
  1468.                 ccladd( anyccl, '\n' );
  1469.                 cclnegate( anyccl );
  1470.  
  1471.                 if ( useecs )
  1472.                     mkeccl( ccltbl + cclmap[anyccl],
  1473.                         ccllen[anyccl], nextecm,
  1474.                         ecgroup, csize, csize );
  1475.  
  1476.                 madeany = true;
  1477.                 }
  1478.  
  1479.             ++rulelen;
  1480.  
  1481.             yyval = mkstate( -anyccl );
  1482.             ;
  1483.     break;}
  1484. case 45:
  1485. #line 581 "parse.y"
  1486. {
  1487.             if ( ! cclsorted )
  1488.                 /* Sort characters for fast searching.  We
  1489.                  * use a shell sort since this list could
  1490.                  * be large.
  1491.                  */
  1492.                 cshell( ccltbl + cclmap[yyvsp[0]], ccllen[yyvsp[0]], true );
  1493.  
  1494.             if ( useecs )
  1495.                 mkeccl( ccltbl + cclmap[yyvsp[0]], ccllen[yyvsp[0]],
  1496.                     nextecm, ecgroup, csize, csize );
  1497.  
  1498.             ++rulelen;
  1499.  
  1500.             yyval = mkstate( -yyvsp[0] );
  1501.             ;
  1502.     break;}
  1503. case 46:
  1504. #line 599 "parse.y"
  1505. {
  1506.             ++rulelen;
  1507.  
  1508.             yyval = mkstate( -yyvsp[0] );
  1509.             ;
  1510.     break;}
  1511. case 47:
  1512. #line 606 "parse.y"
  1513. { yyval = yyvsp[-1]; ;
  1514.     break;}
  1515. case 48:
  1516. #line 609 "parse.y"
  1517. { yyval = yyvsp[-1]; ;
  1518.     break;}
  1519. case 49:
  1520. #line 612 "parse.y"
  1521. {
  1522.             ++rulelen;
  1523.  
  1524.             if ( caseins && yyvsp[0] >= 'A' && yyvsp[0] <= 'Z' )
  1525.                 yyvsp[0] = clower( yyvsp[0] );
  1526.  
  1527.             yyval = mkstate( yyvsp[0] );
  1528.             ;
  1529.     break;}
  1530. case 50:
  1531. #line 623 "parse.y"
  1532. { yyval = yyvsp[-1]; ;
  1533.     break;}
  1534. case 51:
  1535. #line 626 "parse.y"
  1536. {
  1537.             cclnegate( yyvsp[-1] );
  1538.             yyval = yyvsp[-1];
  1539.             ;
  1540.     break;}
  1541. case 52:
  1542. #line 633 "parse.y"
  1543. {
  1544.             if ( caseins )
  1545.                 {
  1546.                 if ( yyvsp[-2] >= 'A' && yyvsp[-2] <= 'Z' )
  1547.                     yyvsp[-2] = clower( yyvsp[-2] );
  1548.                 if ( yyvsp[0] >= 'A' && yyvsp[0] <= 'Z' )
  1549.                     yyvsp[0] = clower( yyvsp[0] );
  1550.                 }
  1551.  
  1552.             if ( yyvsp[-2] > yyvsp[0] )
  1553.                 synerr( "negative range in character class" );
  1554.  
  1555.             else
  1556.                 {
  1557.                 for ( i = yyvsp[-2]; i <= yyvsp[0]; ++i )
  1558.                     ccladd( yyvsp[-3], i );
  1559.  
  1560.                 /* Keep track if this ccl is staying in
  1561.                  * alphabetical order.
  1562.                  */
  1563.                 cclsorted = cclsorted && (yyvsp[-2] > lastchar);
  1564.                 lastchar = yyvsp[0];
  1565.                 }
  1566.  
  1567.             yyval = yyvsp[-3];
  1568.             ;
  1569.     break;}
  1570. case 53:
  1571. #line 661 "parse.y"
  1572. {
  1573.             if ( caseins && yyvsp[0] >= 'A' && yyvsp[0] <= 'Z' )
  1574.                 yyvsp[0] = clower( yyvsp[0] );
  1575.  
  1576.             ccladd( yyvsp[-1], yyvsp[0] );
  1577.             cclsorted = cclsorted && (yyvsp[0] > lastchar);
  1578.             lastchar = yyvsp[0];
  1579.             yyval = yyvsp[-1];
  1580.             ;
  1581.     break;}
  1582. case 54:
  1583. #line 672 "parse.y"
  1584. {
  1585.             cclsorted = true;
  1586.             lastchar = 0;
  1587.             yyval = cclinit();
  1588.             ;
  1589.     break;}
  1590. case 55:
  1591. #line 680 "parse.y"
  1592. {
  1593.             if ( caseins && yyvsp[0] >= 'A' && yyvsp[0] <= 'Z' )
  1594.                 yyvsp[0] = clower( yyvsp[0] );
  1595.  
  1596.             ++rulelen;
  1597.  
  1598.             yyval = link_machines( yyvsp[-1], mkstate( yyvsp[0] ) );
  1599.             ;
  1600.     break;}
  1601. case 56:
  1602. #line 690 "parse.y"
  1603. { yyval = mkstate( SYM_EPSILON ); ;
  1604.     break;}
  1605. }
  1606.    /* the action file gets copied in in place of this dollarsign */
  1607. #line 457 "bison.simple"
  1608.  
  1609.   yyvsp -= yylen;
  1610.   yyssp -= yylen;
  1611. #ifdef YYLSP_NEEDED
  1612.   yylsp -= yylen;
  1613. #endif
  1614.  
  1615. #if YYDEBUG != 0
  1616.   if (yydebug)
  1617.     {
  1618.       short *ssp1 = yyss - 1;
  1619.       fprintf (stderr, "state stack now");
  1620.       while (ssp1 != yyssp)
  1621.     fprintf (stderr, " %d", *++ssp1);
  1622.       fprintf (stderr, "\n");
  1623.     }
  1624. #endif
  1625.  
  1626.   *++yyvsp = yyval;
  1627.  
  1628. #ifdef YYLSP_NEEDED
  1629.   yylsp++;
  1630.   if (yylen == 0)
  1631.     {
  1632.       yylsp->first_line = yylloc.first_line;
  1633.       yylsp->first_column = yylloc.first_column;
  1634.       yylsp->last_line = (yylsp-1)->last_line;
  1635.       yylsp->last_column = (yylsp-1)->last_column;
  1636.       yylsp->text = 0;
  1637.     }
  1638.   else
  1639.     {
  1640.       yylsp->last_line = (yylsp+yylen-1)->last_line;
  1641.       yylsp->last_column = (yylsp+yylen-1)->last_column;
  1642.     }
  1643. #endif
  1644.  
  1645.   /* Now "shift" the result of the reduction.
  1646.      Determine what state that goes to,
  1647.      based on the state we popped back to
  1648.      and the rule number reduced by.  */
  1649.  
  1650.   yyn = yyr1[yyn];
  1651.  
  1652.   yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
  1653.   if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
  1654.     yystate = yytable[yystate];
  1655.   else
  1656.     yystate = yydefgoto[yyn - YYNTBASE];
  1657.  
  1658.   goto yynewstate;
  1659.  
  1660. yyerrlab:   /* here on detecting error */
  1661.  
  1662.   if (! yyerrstatus)
  1663.     /* If not already recovering from an error, report this error.  */
  1664.     {
  1665.       ++yynerrs;
  1666.  
  1667. #ifdef YYERROR_VERBOSE
  1668.       yyn = yypact[yystate];
  1669.  
  1670.       if (yyn > YYFLAG && yyn < YYLAST)
  1671.     {
  1672.       int size = 0;
  1673.       char *msg;
  1674.       int x, count;
  1675.  
  1676.       count = 0;
  1677.       /* Start X at -yyn if nec to avoid negative indexes in yycheck.  */
  1678.       for (x = (yyn < 0 ? -yyn : 0);
  1679.            x < (sizeof(yytname) / sizeof(char *)); x++)
  1680.         if (yycheck[x + yyn] == x)
  1681.           size += strlen(yytname[x]) + 15, count++;
  1682.       msg = (char *) malloc(size + 15);
  1683.       if (msg != 0)
  1684.         {
  1685.           strcpy(msg, "parse error");
  1686.  
  1687.           if (count < 5)
  1688.         {
  1689.           count = 0;
  1690.           for (x = (yyn < 0 ? -yyn : 0);
  1691.                x < (sizeof(yytname) / sizeof(char *)); x++)
  1692.             if (yycheck[x + yyn] == x)
  1693.               {
  1694.             strcat(msg, count == 0 ? ", expecting `" : " or `");
  1695.             strcat(msg, yytname[x]);
  1696.             strcat(msg, "'");
  1697.             count++;
  1698.               }
  1699.         }
  1700.           yyerror(msg);
  1701.           free(msg);
  1702.         }
  1703.       else
  1704.         yyerror ("parse error; also virtual memory exceeded");
  1705.     }
  1706.       else
  1707. #endif /* YYERROR_VERBOSE */
  1708.     yyerror("parse error");
  1709.     }
  1710.  
  1711.   goto yyerrlab1;
  1712. yyerrlab1:   /* here on error raised explicitly by an action */
  1713.  
  1714.   if (yyerrstatus == 3)
  1715.     {
  1716.       /* if just tried and failed to reuse lookahead token after an error, discard it.  */
  1717.  
  1718.       /* return failure if at end of input */
  1719.       if (yychar == YYEOF)
  1720.     YYABORT;
  1721.  
  1722. #if YYDEBUG != 0
  1723.       if (yydebug)
  1724.     fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
  1725. #endif
  1726.  
  1727.       yychar = YYEMPTY;
  1728.     }
  1729.  
  1730.   /* Else will try to reuse lookahead token
  1731.      after shifting the error token.  */
  1732.  
  1733.   yyerrstatus = 3;        /* Each real token shifted decrements this */
  1734.  
  1735.   goto yyerrhandle;
  1736.  
  1737. yyerrdefault:  /* current state does not do anything special for the error token. */
  1738.  
  1739. #if 0
  1740.   /* This is wrong; only states that explicitly want error tokens
  1741.      should shift them.  */
  1742.   yyn = yydefact[yystate];  /* If its default is to accept any token, ok.  Otherwise pop it.*/
  1743.   if (yyn) goto yydefault;
  1744. #endif
  1745.  
  1746. yyerrpop:   /* pop the current state because it cannot handle the error token */
  1747.  
  1748.   if (yyssp == yyss) YYABORT;
  1749.   yyvsp--;
  1750.   yystate = *--yyssp;
  1751. #ifdef YYLSP_NEEDED
  1752.   yylsp--;
  1753. #endif
  1754.  
  1755. #if YYDEBUG != 0
  1756.   if (yydebug)
  1757.     {
  1758.       short *ssp1 = yyss - 1;
  1759.       fprintf (stderr, "Error: state stack now");
  1760.       while (ssp1 != yyssp)
  1761.     fprintf (stderr, " %d", *++ssp1);
  1762.       fprintf (stderr, "\n");
  1763.     }
  1764. #endif
  1765.  
  1766. yyerrhandle:
  1767.  
  1768.   yyn = yypact[yystate];
  1769.   if (yyn == YYFLAG)
  1770.     goto yyerrdefault;
  1771.  
  1772.   yyn += YYTERROR;
  1773.   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
  1774.     goto yyerrdefault;
  1775.  
  1776.   yyn = yytable[yyn];
  1777.   if (yyn < 0)
  1778.     {
  1779.       if (yyn == YYFLAG)
  1780.     goto yyerrpop;
  1781.       yyn = -yyn;
  1782.       goto yyreduce;
  1783.     }
  1784.   else if (yyn == 0)
  1785.     goto yyerrpop;
  1786.  
  1787.   if (yyn == YYFINAL)
  1788.     YYACCEPT;
  1789.  
  1790. #if YYDEBUG != 0
  1791.   if (yydebug)
  1792.     fprintf(stderr, "Shifting error token, ");
  1793. #endif
  1794.  
  1795.   *++yyvsp = yylval;
  1796. #ifdef YYLSP_NEEDED
  1797.   *++yylsp = yylloc;
  1798. #endif
  1799.  
  1800.   yystate = yyn;
  1801.   goto yynewstate;
  1802. }
  1803. #line 693 "parse.y"
  1804.  
  1805.  
  1806.  
  1807. /* build_eof_action - build the "<<EOF>>" action for the active start
  1808.  *                    conditions
  1809.  */
  1810.  
  1811. void build_eof_action()
  1812.     {
  1813.     register int i;
  1814.     char action_text[MAXLINE];
  1815.  
  1816.     for ( i = 1; i <= actvp; ++i )
  1817.         {
  1818.         if ( sceof[actvsc[i]] )
  1819.             format_pinpoint_message(
  1820.                 "multiple <<EOF>> rules for start condition %s",
  1821.                 scname[actvsc[i]] );
  1822.  
  1823.         else
  1824.             {
  1825.             sceof[actvsc[i]] = true;
  1826.             sprintf( action_text, "case YY_STATE_EOF(%s):\n",
  1827.             scname[actvsc[i]] );
  1828.             add_action( action_text );
  1829.             }
  1830.         }
  1831.  
  1832.     line_directive_out( (FILE *) 0 );
  1833.  
  1834.     /* This isn't a normal rule after all - don't count it as
  1835.      * such, so we don't have any holes in the rule numbering
  1836.      * (which make generating "rule can never match" warnings
  1837.      * more difficult.
  1838.      */
  1839.     --num_rules;
  1840.     ++num_eof_rules;
  1841.     }
  1842.  
  1843.  
  1844. /* format_synerr - write out formatted syntax error */
  1845.  
  1846. void format_synerr( msg, arg )
  1847. char msg[], arg[];
  1848.     {
  1849.     char errmsg[MAXLINE];
  1850.  
  1851.     (void) sprintf( errmsg, msg, arg );
  1852.     synerr( errmsg );
  1853.     }
  1854.  
  1855.  
  1856. /* synerr - report a syntax error */
  1857.  
  1858. void synerr( str )
  1859. char str[];
  1860.     {
  1861.     syntaxerror = true;
  1862.     pinpoint_message( str );
  1863.     }
  1864.  
  1865.  
  1866. /* warn - report a warning, unless -w was given */
  1867.  
  1868. void warn( str )
  1869. char str[];
  1870.     {
  1871.     line_warning( str, linenum );
  1872.     }
  1873.  
  1874. /* format_pinpoint_message - write out a message formatted with one string,
  1875.  *                 pinpointing its location
  1876.  */
  1877.  
  1878. void format_pinpoint_message( msg, arg )
  1879. char msg[], arg[];
  1880.     {
  1881.     char errmsg[MAXLINE];
  1882.  
  1883.     (void) sprintf( errmsg, msg, arg );
  1884.     pinpoint_message( errmsg );
  1885.     }
  1886.  
  1887.  
  1888. /* pinpoint_message - write out a message, pinpointing its location */
  1889.  
  1890. void pinpoint_message( str )
  1891. char str[];
  1892.     {
  1893.     line_pinpoint( str, linenum );
  1894.     }
  1895.  
  1896.  
  1897. /* line_warning - report a warning at a given line, unless -w was given */
  1898.  
  1899. void line_warning( str, line )
  1900. char str[];
  1901. int line;
  1902.     {
  1903.     char warning[MAXLINE];
  1904.  
  1905.     if ( ! nowarn )
  1906.         {
  1907.         sprintf( warning, "warning, %s", str );
  1908.         line_pinpoint( warning, line );
  1909.         }
  1910.     }
  1911.  
  1912.  
  1913. /* line_pinpoint - write out a message, pinpointing it at the given line */
  1914.  
  1915. void line_pinpoint( str, line )
  1916. char str[];
  1917. int line;
  1918.     {
  1919.     fprintf( stderr, "\"%s\", line %d: %s\n", infilename, line, str );
  1920.     }
  1921.  
  1922.  
  1923. /* yyerror - eat up an error message from the parser;
  1924.  *         currently, messages are ignore
  1925.  */
  1926.  
  1927. void yyerror( msg )
  1928. char msg[];
  1929.     {
  1930.     }
  1931.